<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <script src="./js/earthsdk.js"></script>
    <!-- 自定义Css样式 -->
    <link rel="stylesheet" href="./css/example1.css">
    <title>Cesium地球初始化</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }

        .box {
            display: grid;
            grid-template-columns: 80px 1fr;
        }

        .btn {
            display: flex;
            padding-top: 10px;
        }
    </style>
</head>

<body>
    <div id="app"></div>

    <div id="panel">
        <button onclick="flyTo()">开始多段飞行</button>
    </div>
    <script>
        /** ---------------------------------地球创建------------------------------------**/
        // Vue中引入方式：import { ESObjectsManager } from 'earthsdk3';
        const { ESObjectsManager, ESCameraViewCollection } = window['EarthSDK3']
        const { ESCesiumViewer } = window['EarthSDK3_Cesium']
        const { ESUeViewer } = window['EarthSDK3_UE']

        const objm = new ESObjectsManager(ESCesiumViewer, ESUeViewer);
        window.g_objm = objm;
        // 创建Cesium视口
        const viewer = objm.createCesiumViewer({
            type: 'ESCesiumViewer',
            container: document.getElementById("app"),
        });

        // 通过json创建一个影像图层
        const imageryLayer = objm.createSceneObjectFromJson({
            "id": "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
            "type": "ESImageryLayer",
            "maximumLevel": 16,
            "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
        });

        /** --------------------------飞行定位----------------------------------**/
        const esCameraViewCollection = objm.createSceneObject(ESCameraViewCollection)
        esCameraViewCollection.views = [
            {
                "duration": 5,
                "position": [
                    118.41987506663914,
                    34.50924791105231,
                    14540.233288604311
                ],
                "rotation": [
                    308.04032837777527,
                    -31.40037868112815,
                    0.006408636367614372
                ],
                "thumbnail": "",
                "name": "视角1"
            },
            {
                "duration": 5,
                "position": [
                    118.27320208326312,
                    34.721576462110654,
                    3610.1818978722195
                ],
                "rotation": [
                    351.6035617021979,
                    -34.152491794746844,
                    0.03998306978890789
                ],
                "thumbnail": "",
                "name": "视角2"
            },
            {
                "duration": 5,
                "position": [
                    118.27249244068592,
                    34.78650162834411,
                    997.4923333558179
                ],
                "rotation": [
                    62.59131969407766,
                    -22.129793360715006,
                    0.008534471339022827
                ],
                "thumbnail": "",
                "name": "视角3"
            },
            {
                "duration": 5,
                "position": [
                    118.33872201001793,
                    34.815321277005914,
                    1007.5447109494668
                ],
                "rotation": [
                    62.591295159323224,
                    -22.129762076044212,
                    0.008599601096928955
                ],
                "thumbnail": "",
                "name": "视角4"
            },
            {
                "duration": 5,
                "position": [
                    118.36017490569138,
                    34.83241736218279,
                    1236.576367000374
                ],
                "rotation": [
                    37.259808646784144,
                    -25.921946177625557,
                    359.9964468616669
                ],
                "thumbnail": "",
                "name": "视角5"
            }
        ]
        // 是否循环播放
        esCameraViewCollection.loop = true
        // 播放间隔时间
        esCameraViewCollection.intervalTime = 0


        const flyTo = () => {
            // 自动飞行播放
            esCameraViewCollection.playing = true
        }


    </script>

    <!-- 切换UE和Cesium引擎的组件（Vue） -->
    <div id="root">
        <switch-engine :objm="objm"></switch-engine>
    </div>
    <!-- Vue文件 -->
    <script src="./js/vue.global.js"></script>
    <!-- 切换UE和Cesium的组件 -->
    <script src="./js/switchEngineCom.js"></script>
</body>

</html>